/*
package com.cskaoyan.service;


import com.cskaoyan.bean.market.Storage;
import com.cskaoyan.bean.market.StorageCreateVo;
import com.cskaoyan.mapper.StorageMapper;
import com.cskaoyan.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Date;

@Service
public class StorageServiceImpl implements StorageService {

    @Autowired
    StorageMapper storageMapper;

    @Override
    public StorageCreateVo create(HttpServletRequest request,MultipartFile myltifile) {
        //文件大小
        long size = myltifile.getSize();
        //原始文件名
        String name = myltifile.getOriginalFilename();
        String type = "image/jpeg";
        String requestURI = request.getRequestURI();
        String key = RandomUtil.getUUID1() + ".gpg";
        //TODO 写在配置文件当中，不能直接写死
        String url = "http://192.168.8.87:8083" + requestURI + "/" + key;
        File file = new File("D:\\ProjectPictures", key);
        try {
            myltifile.transferTo(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Storage storage = new Storage();
        storage.setKey(key);
        storage.setName(name);
        storage.setType(type);
        storage.setSize((int) size);
        storage.setUrl(url);
        Date time = new Date();
        storage.setAddTime(time);
        storage.setUpdateTime(time);
        int id = storageMapper.insertSelective(storage);
        StorageCreateVo storageCreateVo = new StorageCreateVo();
        storageCreateVo.setId(id);
        storageCreateVo.setKey(key);
        storageCreateVo.setName(name);
        storageCreateVo.setType(type);
        storageCreateVo.setSize((int) size);
        storageCreateVo.setUrl(url);
        storageCreateVo.setAddTime(time);
        storageCreateVo.setUpdateTime(time);
        return storageCreateVo;
    }
}
*/
